package com.zhhq.utils;


import com.zhhq.enums.ResultEnum;
import com.zhhq.model.Result;

/**
 * 返回结果帮助类
 * Created by HeChaobin on 2017-05-29.
 */
public class ResultUtil {

    /**
     * 返回成功
     * @param object
     * @return
     */
    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(object);
        return result;
    }

    /**
     * 返回成功
     * @return
     */
    public static Result success() {
        return success(null);
    }

    /**
     * 返回错误
     * @param code
     * @param msg
     * @return
     */
    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}
